public class Day3_2_数组中超过一半的数字 {
    public int MoreThanHalfNum_Solution(int [] array) {
        int result = array[0];
        int flag = 1;
        for(int i = 1; i < array.length; i++){
            if(flag == 0){
                result = array[i];
                flag = 1;
            }
            if(result == array[i]){
                flag++;
            }else{
                flag--;
            }
        }
        return result;
    }
}
